package com.haha;

import com.entity.MessageInfo;

import java.util.Iterator;
import java.util.ServiceLoader;

public class ExectorFactory {
    public IExecutor iExecutor;

    public void getInstance(MessageInfo info) {
        if(info == null) {
            throw new RuntimeException("参数为空");
        }

        ServiceLoader<IExecutor> serviceLoader = ServiceLoader.load(IExecutor.class);

        Iterator<IExecutor> iterator = serviceLoader.iterator();
        while(iterator.hasNext()) {
            IExecutor executor = iterator.next();
            executor.handleMessage(info);
        }

        String action = info.getAction();
    }
}
